<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <link rel="stylesheet" type="text/css" href="/Public/uploadfy/uploadify.css" />
    <script type="text/javascript" src="/Public/uploadfy/jquery.uploadify.min.js"></script>
    <style>
        #dg{
            height: 100%;;
        }
    </style>
</block>
<block name="bdoy">
    <body>
    <table id="grid_waterele_log"></table>
    <div id="grid_waterele_log_ToolBar" style="padding:5px;height:auto">
        <div id="queryParamZone_waterele_log">
            <form id="queryForm_Waterelelog" method="post" action="">
                <div>
                    <input type="hidden" name="pumpid" id="search_form_station_id"/>
                    <table>
                        <tr>
                            <td>从：</td>
                            <td><input class="easyui-datebox" name="start" style="width: 100px;"></td>
                            <td>到：</td>
                            <td><input class="easyui-datebox" name="end" style="width: 100px;"></td>
                            <td><span><a id="btnQueryWaterelelog" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a></span></td>
                            <td><a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:$('#queryForm_Waterelelog').form('clear');">重置</a></td>
                        </tr>
                    </table>

                </div>
            </form>
        </div>
    </div>

    </body>
</block>
<block name="footExtendJs">
    <script type="text/javascript">
        //$.noConflict();

        $(window).resize(function() {
            $('#grid_waterele_log').datagrid('resize');
        });

        function clearwaterelelogForm(){
            $('#waterelelogForm').form('clear');
        }

        function clearQueryParamZone(){
            $('#queryForm_Waterelelog').form('clear');
        }

        $(function(){
            $('#grid_waterele_log').datagrid({
                //title:'水电表',
                width: '100%',
                //height: 400,
                fit: true,
                nowrap: false,
                striped: true,
                collapsible:false,
                url:'/Manage/AdminPumpWaterele/log_get_all',
                queryParams:{eleid:{:I('get.fy_id')},page:1,rows:20},
                method:'get',
                pageNumber:1,
                pageSize:20,
                idField:'id',
                sortName: 'id',
                sortOrder: 'desc',
                remoteSort: false,
                columns:[[
                    {field:'id',title:'序号',width:60,checkbox:true},
                    {field:'sta_name',title:'泵站名称',width:180,align:'center'},
                    {field:'we_number',title:'电表编号',width:100,align:'center'},
                    {field:'we_name',title:'电表名称',width:100,align:'center'},
                    {field:'date',title:'填报日期',width:140,align:'center'},
                    {field:'pump_pfa',title:'锋正向有功',width:140,align:'center'},
                    {field:'pump_rta',title:'平正向有功',width:140,align:'center'},
                    {field:'pump_lta',title:'谷正向有功',width:120,align:'center'},
                    {field:'pump_fa',title:'正向有功',width:120,align:'center'},
                    {field:'pump_nfa',title:'正向无功',width:120,align:'center'},
                    {field:'pump_ra',title:'反向无功',width:120,align:'center'},

                ]],
                pagination:true,
                rownumbers:true,
                singleSelect:true,
                toolbar: '#grid_waterele_log_ToolBar',

                onLoadSuccess: function(data) {
                    $(this).datagrid('resize');

                }
            });

            $('#btnQueryWaterelelog').click(function() {
                var obj = $('#queryForm_Waterelelog').serializeJson();
                obj['eleid'] = {:I('get.fy_id')};
                $('#grid_waterele_log').datagrid('load',obj);
            });


        });

        function editWaterelelog(id) {
            if(id!=""){
                $("#saveflag_waterele_log").val("update");
            }else{
                clearwaterelelogForm();
                $("#saveflag_waterele_log").val("add");
                return;
            }
            $.ajax({url:"/Manage/AdminPumpWaterele/get_obj_log_json",data:{id:id},dataType:"json",success:function(json, textStatus){
                $('#eleid').combobox('reload','/Manage/AdminPumpWaterele/get_all_waterele?ps_id='+json.station);
                $('#waterelelogForm').form('load',{
                    "id": json.id,
                    "date": json.date,
                    'station' : json.station,
                    "eleid": json.eleid,
                    "pump_pfa": json.pump_pfa,
                    "pump_rta": json.pump_rta,
                    "pump_lta": json.pump_lta,
                    "pump_fa": json.pump_fa,
                    "pump_nfa": json.pump_nfa,
                    "pump_ra": json.pump_ra,
                    "pump_waterdegrees": json.pump_waterdegrees
                });
                $('#waterelelogDlg').dialog({title:'编辑水电表信息',modal:true});
                $('#waterelelogDlg').dialog("open");
                setFormFocus('#waterelelogForm');
            },error:function(XMLHttpRequest, textStatus, errorThrown) {
                relogin(XMLHttpRequest, textStatus, errorThrown);
            }});
        }

        function submitwaterelelogForm() {
            if ($('#waterelelogForm').form('validate')) {
                var submitflag = $("#saveflag_waterele_log").val();
                var url = "";
                if (submitflag === "add")
                    url = "/Manage/AdminPumpWaterele/log_add";
                if (submitflag === "update")
                    url = "/Manage/AdminPumpWaterele/log_edit";
                $('#waterelelogForm').ajaxSubmit({
                    url:url,
                    dataType:'json',
                    success: function(data) {
                        if (data.status==1) {
                            if (submitflag === "add") $('#grid_waterele_log').datagrid('load');
                            if (submitflag === "update") $('#grid_waterele_log').datagrid('reload');
                            $('#waterelelogDlg').dialog("close");
                            $.messager.show({title:'提示',msg:'保存成功！',showType:'slide'});
                        }
                        else $.messager.alert('提示','操作失败！','error');
                    }
                });
            }else{
                console.log('no valdate');
            }
        }
    </script>
</block>